Skip to content

Add TLS CA-file override for private CAs (#13) - #18

Merged
sidick merged 2 commits into
mainfrom
tls-ca-file-override
Aug 30, 2026
Merged

Add TLS CA-file override for private CAs (#13)#18
sidick merged 2 commits into
mainfrom
tls-ca-file-override

Conversation

@sidick

@sidick sidick commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Closes TLS: CA-file override for private CAs #13: adds a CAFILE/-c escape hatch for brokers behind a private CA, so certificate verification can stay on instead of falling back to TLSINSECURE/-S.
  • New ca_file/mco_CAFile field threaded through tool_opts, both TLS transports (transport_openssl.c, transport_amissl.c), mqtt.library's MqttConnectOpts, and both CLI flavors (host -c, Amiga CAFILE/K).
  • SSL_CTX_load_verify_locations() is additive on top of the existing default trust store / AmiSSL cert store, not a replacement - a broker behind a normal public CA still verifies too.
  • Docs: mqtt.doc/mqtt-library-reference.md regenerated, CLI-Reference.md updated with the new flags plus a new "A note on TLS and the system clock" section (see below).
  • New on-target test: tests/library/libcafile.c + cafile-run.sh (make library-cafile-smoke), same local-only/amibake-image shape as the existing library-tls-smoke.

A real finding along the way

Verifying this on-target surfaced a genuine gotcha, now documented: the Amiga's system clock matters for certificate verification. A wrong/unseeded clock makes a good certificate look not-yet-valid or expired. The test harness itself hit this (Copperline's guest clock needs --rtc-time seeding, and even seeded there's enough skew - not pinned down further, not worth chasing for a test harness - to need certs backdated by a day for margin, see cafile-run.sh's banner comment).

Test plan

  • Host: mqtt_pub-host -s <broker with private-CA cert> fails without -c, succeeds with -c capath.pem.
  • On-target (real m68k + AmiSSL under Copperline, via a purpose-built low-level diagnostic and the real mco_CAFile API): confirmed the exact same behavior, and root-caused an initial on-target-only failure to the clock-skew issue above (not a code bug).
  • sh tests/library/cafile-run.sh: full green run against an amibake-built AmigaOS 3.2.2 + AmiSSL image - both checks pass (no-cafile-connect-fails, with-cafile-connect-ok).
  • sh tests/library/tls-run.sh (existing mco_TLS test, no CA file): still full green - no regression.
  • make test: 249/249 host unit tests pass.
  • mkdocs build --strict and docs2guide.py conversion both clean.
  • make m68k, make library (with and without make fetch-amissl-sdk), make cli all build with no warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QWq1CRLCQy9AaD9UtLRSM9

sidick and others added 2 commits August 30, 2026 11:25
midge.readme and userdocs/index.md still said TLS was "planned for
future releases" - stale since the AmiSSL transport landed and shipped
in mqtt.library/mqtt_pub/mqtt_sub. Both now describe it as available
(mco_TLS/TLS-TLSINSECORE, AmiSSL required separately, CPU-speed caveat).

Installation.md gets a new "Installing AmiSSL (needed for TLS)" section
alongside the existing mqtt.library install step - the missing piece a
release user would actually need to discover TLS is usable at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWq1CRLCQy9AaD9UtLRSM9
Threads a new ca_file/mco_CAFile/-c/CAFILE option end-to-end through
both TLS transports and both CLI flavors:

- src/tools/tool_opts.h: new ca_file field, parsed by both host getopt
  (-c) and Amiga ReadArgs (CAFILE/K).
- src/host/transport_openssl.c and src/amiga/transport_amissl.c: an
  extra SSL_CTX_load_verify_locations() call when ca_file is set,
  additive to the existing default trust store/AmiSSL cert store (not a
  replacement), so brokers behind a public CA keep verifying too.
- mqtt.library: new mco_CAFile field on MqttConnectOpts, deep-copied at
  MQTT_CreateClient() time like the other string options, threaded
  through child_connect() into the AmiSSL branch. Host/library-linked
  Amiga CLIs pass their new -c/CAFILE value straight through; the
  static Amiga CLIs already reject TLS outright so need no change.
- mqtt.doc/mqtt-library-reference.md and CLI-Reference.md updated
  (including host `-c` and Amiga `CAFILE`).

Verified end-to-end on real m68k/AmiSSL under Copperline: a broker cert
signed by a private CA correctly fails without the CA file and succeeds
with it (both the host CLI and the real mqtt.library path). Along the
way, found and documented a real gotcha for anyone doing certificate
verification on Amiga: the guest clock matters a lot (a wrong or
unseeded clock makes a good certificate look not-yet-valid/expired) -
new "A note on TLS and the system clock" in CLI-Reference.md.

Adds tests/library/libcafile.c + cafile-run.sh (make
library-cafile-smoke), same local-only/amibake-image shape as the
existing library-tls-smoke.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWq1CRLCQy9AaD9UtLRSM9
@sidick
sidick merged commit 1226fc1 into main Aug 30, 2026
11 checks passed
@sidick
sidick deleted the tls-ca-file-override branch August 30, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TLS: CA-file override for private CAs

1 participant